package com.znxs.zuopao_c.once;

import com.alibaba.excel.EasyExcel;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 导入星球用户到数据库
 */
public class ImportOutSideUser {

    public static void main(String[] args) {

        String filePath = "D:\\package\\project\\userCenter\\user_center_c\\src\\main\\resources\\testExcel.xlsx";

        // 从excel 读取数据
        List<OutSideData> OutSideDataList = EasyExcel.read(filePath).head(OutSideData.class).sheet().doReadSync();
        System.out.println("总数="+OutSideDataList.size());
        // 处理数据
        Map<String, List<OutSideData>> listMap = OutSideDataList.stream()
                // 过滤非空数据
                .filter(OutSideData -> StringUtils.isNotBlank(OutSideData.getNickname()))
                // 根据昵称分组 进行分组使得数据筛选重复数据
                .collect(Collectors.groupingBy(OutSideData::getNickname));

        System.out.println("不重复的数据条数="+listMap.keySet().size());

    }


}
